﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QuanLyGiaoVuDAL.DTO;
using AutoMapper;
using QuanLyGiaoVuUI.Models.MonHoc;

namespace QuanLyGiaoVuUI.Models.SinhVien
{
    public class BangDiemViewModel
    {
        public Guid MaBangDiem { get; set; }
        public Guid SinhVienId { get; set; }
        public Guid MaMonHoc { get; set; }
        public float DiemHocPhan { get; set; }
        public Guid MaHocKy { get; set; }

        public MonHocDTO MonHoc { get; set; }
        public HocKyDTO HocKy { get; set; }
        public NamHocDTO NamHoc { get; set; }
        

        public BangDiemDTO ToBangDiemDTO()
        {
            Mapper.CreateMap(typeof(BangDiemViewModel), typeof(BangDiemDTO));
            var bangDiemDTO = new BangDiemDTO();
            Mapper.Map(this, bangDiemDTO);
            return bangDiemDTO;
        }

        public static BangDiemViewModel FromBangDiemDTO(BangDiemDTO bangDiemDTO)
        {
            Mapper.CreateMap(typeof(BangDiemDTO), typeof(BangDiemViewModel));
            var bangDiemViewModel = new BangDiemViewModel();
            Mapper.Map(bangDiemDTO, bangDiemViewModel);
            return bangDiemViewModel;
        }

        public static IEnumerable<BangDiemViewModel> FromBangDiemDTOList(IEnumerable<BangDiemDTO> bangDiemDTOList)
        {
            List<BangDiemViewModel> bangDiemViewModelList = new List<BangDiemViewModel>();
            foreach (BangDiemDTO bangDiemDTO in bangDiemDTOList)
            {
                bangDiemViewModelList.Add(BangDiemViewModel.FromBangDiemDTO(bangDiemDTO));
            }
            return bangDiemViewModelList.AsEnumerable<BangDiemViewModel>();
        }
    }
}